package com.sky.controller.langzhu;

import com.sky.entity.Massage;
import com.sky.result.Result;
import com.sky.service.LangZhuService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "狼蛛相关api")
@RestController
@Slf4j
@RequestMapping("/langzhu")
public class LangZhuController {
    @Autowired
    private LangZhuService langZhuService;
    String info ="反馈提交成功";
    String error = "反馈提交失败";
    @PostMapping("/postMassage")
    public Result<String> postMassage(@RequestBody Massage massage){
        int i=langZhuService.PostMassage(massage);
        String msg;
        if (i==1){
            msg = info;
        }else{
            msg = error;
        }
        return Result.success(msg);
    }

    @GetMapping("/getMassage")
    public Result<String[]> GetMassage(){
        String[] allMassage = langZhuService.GetMassage();
        System.out.println(allMassage);
        return Result.success(allMassage);
    }
}
